//
//  DetailCellFour.swift
//  CompareBuying
//
//  Created by 唐先才 on 16/2/18.
//  Copyright © 2016年 唐先才. All rights reserved.
//

import UIKit

class DetailCellFour: UITableViewCell {
    
    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var titleLab: UILabel!
    @IBOutlet weak var priceLab: UILabel!
    
    func configCellWithModel(model: TxcModel) {
        guard let iconImg = model.MainImage, title = model.InfoTitle, price = model.CommodityPrice else {
            print("detailCellFour赋值失败")
            return
        }
        iconView.sd_setImageWithURL(NSURL(string: iconImg))
        titleLab.text = title
        priceLab.text = price
    }
    
    static func detailCellFourWith(tableView: UITableView, dataArray: NSMutableArray, indexPath: NSIndexPath) -> UITableViewCell {
        if indexPath.row == 0 {
            let cell4 = UITableViewCell(style: .Default, reuseIdentifier: "cell4")
            guard let cell4Lab = cell4.textLabel else {
                return UITableViewCell()
            }
            cell4Lab.text = "猜你喜欢"
            cell4Lab.textColor = UIColor.blackColor()
            cell4Lab.font = UIFont.systemFontOfSize(13)
            return cell4
        }
        if let detailCellFour = tableView.dequeueReusableCellWithIdentifier("detailCellFour") as? DetailCellFour {
            if dataArray.count > 0 {
                if let model = dataArray[indexPath.row - 1] as? TxcModel {
                    detailCellFour.configCellWithModel(model)
                }
            }
            return detailCellFour
        }
        return UITableViewCell()
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
